package at.fhj.antesk.steamvaluecalc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import at.fhj.antesk.steamvaluecalc.resources.Configs;

public class DatabaseAccess {
	
	private Connection connection;
	private static Logger logger = LoggerFactory.getLogger(DatabaseAccess.class);
	private Map<String, String> configsMap = Configs.getInstance().getConfigsMap();
	
	public Connection getConnection() {
		return connection;
	}

	public DatabaseAccess(){
		try {
			String database = configsMap.get("database.localhost.url");
			String user = configsMap.get("database.username.local");
			String pass = configsMap.get("database.password.local");
			connection = DriverManager.getConnection(database, user, pass);
		} catch (SQLException e) {
			logger.error("Error establishing database connection", e);
		}
	}
}
